<?php
/**
 * @yiwan
 * 最后关联wiki的uid
 * 最后关联wiki分类的uid
 */

use Biz\model\TodayNiceGoods\TodayNiceGoodsModel;
use Doraemon\ali\model\TodayNiceGoods as ATodayNiceGoods;
use Biz\model\wiki\Wiki;


ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';

 $info =  TodayNiceGoodsModel::all(['status' => TodayNiceGoodsModel::STATUS_NORMAL]);
 if($info && is_array($info)){
      foreach ($info as $val){
          $wiki_info = Wiki::getInfoByWikiId($val['wiki_id']);
          if (!$wiki_info) {
              var_dump("空");
             continue;
          }
          if($wiki_info['channel'] != Wiki::CHANNEL_TAOBAO ){
              var_dump("</n>非淘宝");
             continue;
          }
          $channel_spu_id = $wiki_info['channel_spu_id'];
          $timeGoods = ATodayNiceGoods::get("*" ,['start_time' => $val['start_at'] ,'show_status'=> ATodayNiceGoods::STATUS_NORMAL ]);
          $data = [
              'wiki_id' => $val['wiki_id'],
              'channel_spu_id' =>$channel_spu_id,
              'title' => $val['title'],
              'sec_title' =>$val['sec_title'],
              'wiki_img' => $val['img'],
              'back_img' => $val['back_img'],
              'stand_img' => $val['back_show_img'],
              'start_time' => $val['start_at'],
              "end_time" =>$val['end_at'],
              "month" => $val['month'],
              'tags' =>  $val['tags'],
              'show_status' => ATodayNiceGoods::STATUS_NORMAL,
              'edittime' => date('Y-m-d H:i:s', time()),
              'admin_id' => $val['admin_id']
          ];
          if($timeGoods){
              ATodayNiceGoods::updateByWhere($data , ['id' => $timeGoods['id']]);
          }else{
              ATodayNiceGoods::InsertData($data );
          }
      }
 }







